//
//  SVCustomButton.m
//  SilenceVoice
//
//  Created by 张诗宇 on 16/1/27.
//  Copyright © 2016年 张诗宇. All rights reserved.
//

#import "SVCustomButton.h"

@implementation SVCustomButton

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
 
 */

// 重写系统方法设置image在button上的位置
- (CGRect)imageRectForContentRect:(CGRect)contentRect {
    
    CGFloat imageWidth = contentRect.size.width;
    CGFloat imageHeight = contentRect.size.height * 0.6;
    
    return CGRectMake(0, 0, imageWidth, imageHeight);
}

// 重写系统方法设置title在button上的位置
- (CGRect)titleRectForContentRect:(CGRect)contentRect {
    
    CGFloat titleY = contentRect.size.height * 0.5;
    CGFloat titleWidth = contentRect.size.width;
    CGFloat titleHeight = contentRect.size.height - titleY;
    
    return CGRectMake(0, titleY, titleWidth, titleHeight);
}

@end
